package com.jrowny
{
	import com.jrowny.commands.ElementsChangedCommand;
	import com.jrowny.commands.ExportCSSCommand;
	import com.jrowny.commands.ExportHTMLCommand;
	import com.jrowny.commands.ImageLoadedCommand;
	import com.jrowny.commands.OpenFileCommand;
	import com.jrowny.commands.PreviewInBrowserCommand;
	import com.jrowny.commands.StartupCommand;
	
	import org.puremvc.as3.patterns.facade.Facade;
	import com.jrowny.enum.Notes;
	
	public class ApplicationFacade extends Facade
	{
		/**
		 * Used to keep this object a singleton
		 */
		public static function getInstance() : ApplicationFacade {
			if ( instance == null ) instance = new ApplicationFacade( );
			return instance as ApplicationFacade;
		} 

		/**
		 * Run this function to send the startup notification and pass the whole application as an object
		 */
		public function startup(app:Object):void{
			this.sendNotification(Notes.STARTUP,app);
		}
		
		/**
		 * This function registers notes to commands
		 */
		override protected function initializeController():void{
			super.initializeController();
			
			//register commands
			registerCommand(Notes.STARTUP,StartupCommand);
			registerCommand(Notes.OPEN_FILE,OpenFileCommand);
			registerCommand(Notes.IMAGE_LOADED,ImageLoadedCommand);
			registerCommand(Notes.EXPORT_CSS,ExportCSSCommand);
			registerCommand(Notes.EXPORT_HTML,ExportHTMLCommand);
			registerCommand(Notes.ELEMENTS_CHANGED,ElementsChangedCommand);
			registerCommand(Notes.PREVIEW_IN_BROWSER,PreviewInBrowserCommand);
		}
	}
}